package com.steam.xbcc.controller;

import com.steam.xbcc.dto.SmsCodeDto;
import com.steam.xbcc.result.JSONResult;
import com.steam.xbcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult verifycodeImageCode(@PathVariable("imageCodeKey") String imageCodeKey){
        return JSONResult.success(verifyCodeService.image(imageCodeKey));
    }

    @RequestMapping(value = "/sendSmsCode", method = RequestMethod.POST)
    public JSONResult verifycodeSendSmsCode(@RequestBody SmsCodeDto smsCodeDto){
        verifyCodeService.verify(smsCodeDto);
        return JSONResult.success();
    }

}
